//
//  Color.swift
//  Box
//
//  Created by mn on 2025/3/28.
//

import UIKit

extension UIColor {
    static let gold = UIColor.init(hex: "#E7AB4B")
    
    static var darkGrayCustom: UIColor {
        return UIColor.fromHex("#313131")
    }
    
    static func fromHex(_ hex: String) -> UIColor {
        UIColor(hex: hex)
    }
    convenience init(hex: String) {
        var hexSanitized = hex.trimmingCharacters(in: .whitespacesAndNewlines)
        hexSanitized = hexSanitized.replacingOccurrences(of: "#", with: "")

        var rgb: UInt64 = 0
        Scanner(string: hexSanitized).scanHexInt64(&rgb)

        let r = CGFloat((rgb & 0xFF0000) >> 16) / 255.0
        let g = CGFloat((rgb & 0x00FF00) >> 8) / 255.0
        let b = CGFloat(rgb & 0x0000FF) / 255.0

        self.init(red: r, green: g, blue: b, alpha: 1.0)
    }
}
